#pragma once
#include "CLComValue.h"
#include "CLComString.h"
#include "CDataFile.h"
#include "CLComLibrarys_global.h"
#include "CRecordItem.h"
//CLCOMLIBRARYS_EXPORT

enum EAOILOGIC_RETURN_VALUE
{
	ERECORD_RETURN_VALUE_FALSE = 0,
	ERECORD_RETURN_VALUE_OK,
};

class CLCOMLIBRARYS_EXPORT CAttribute
{
public:
    CAttribute(CLComString pathName);
    ~CAttribute();
	void Release();

public:
    static void Copy(CAttribute* pdst, const CAttribute* psrc);
public:
    void RegisterAttribute(CLComString key, ECLCOMVALUE_TYPE type);
    int ModifyAttribute(CLComValue& item);
    void GetAttributes(map<string, CLComValue>& outAttributes) const;
    int GetAttribute(CLComValue& item) const;
	void ClearAttributes();
    void LoadFromFile(CLComString fileName);

public:
	bool GoBack(int nIndex = -1);
	bool GoNext(int nIndex = -1);
	int  BackUp(CRecordItem& recordinfo);
	void Update();

	void ClearBackup();
	void Save2File(FILE* file);
private:
    ECLCOMVALUE_TYPE SupportAttribute(CLComString key);
    void CreateAttribute(CLComString pathName);
    int GetAttributeAux(CLComValue& item, CDataFile* pDataFile)const;
private:
    CDataFile*                          m_pDataFile;
    map<CLComString, ECLCOMVALUE_TYPE>	m_mapSupportAttributes;
};

